﻿using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;
using Qas.CommonLogic;
using Qas.CommonLogic.BusinessObjects;

namespace Qas.CommonLogic.Business_Objects.Graph
{ 
    public class PriorityQueue : IEnumerable
    {
        /// <summary>
        /// Бинарная куча для хранения состояний
        /// </summary>
        private BinaryHeap heap;

        public PriorityQueue()
        {
            this.heap = new BinaryHeap();
        }

        /// <summary>
        /// Добавения состояния в очередь
        /// </summary>
        /// <param name="state"></param>
        public void Enqueue(State state)
        {
            this.heap.Insert(state);
        }

        //public bool Contains(Task task)
        //{
        //    return this.heap.Contains(task);
        //}

        public List<State> getElements()
        {
           return this.heap.getAll();
        }

        //public void Enqueue(int state)
        //{
        //    this.heap.Insert(state);
        //}

        /// <summary>
        /// Взятие из очереди состояния с лучшим приоритетом
        /// </summary>
        /// <returns></returns>
        public State Dequeue()
        {
            return this.heap.Remove();
        }

        public State GetFirst()
        {
            return this.heap.GetRoot();
        }

        //public State GetLast()
        //{
        //    return this.
        //}

        public string ToString()
        {
            return this.heap.ToString();
        }


        #region ICollection Members

        public void CopyTo(Array array, int index)
        {
            throw new NotImplementedException();
        }

        public int Count
        {
            get { return this.heap.Count; }

        }

        public bool IsSynchronized
        {
            get { throw new NotImplementedException(); }
        }

        public object SyncRoot
        {
            get { throw new NotImplementedException(); }
        }

        #endregion

        #region IEnumerable Members

        public IEnumerator GetEnumerator()
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}
